/*===========================================================================
  Copyright (C) 2014 by the Okapi Framework contributors
-----------------------------------------------------------------------------
  This library is free software; you can redistribute it and/or modify it 
  under the terms of the GNU Lesser General Public License as published by 
  the Free Software Foundation; either version 2.1 of the License, or (at 
  your option) any later version.

  This library is distributed in the hope that it will be useful, but 
  WITHOUT ANY WARRANTY; without even the implied warranty of 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 
  General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License 
  along with this library; if not, write to the Free Software Foundation, 
  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

  See also the full LGPL text here: http://www.gnu.org/copyleft/lesser.html
===========================================================================*/

package net.sf.okapi.v2.common.om;

import net.sf.okapi.v2.common.LocaleId;

/**
 * Represents a unit of extracted content. Usually a text unit corresponds to a "paragraph" (for example
 * the content of a <code>&lt;p></code> element in HTML, a string entry in a properties file, etc.
 */
public interface ITextUnit extends IGroupOrUnit, IWithStore {

	/**
	 * Gets the source container for this unit.
	 * @return the source container for this unit (never null).
	 */
	public ITextContainer getSource ();
	
	/**
	 * Gets the container for a given target locale.
	 * @param trgLoc the target locale.
	 * @return the container for a given target locale, null if it does not exists.
	 * @see #getTarget(LocaleId, GetTarget)
	 */
	public ITextContainer getTarget (LocaleId trgLoc);
	
	/**
	 * Gets the container for a given target locale and the given option.
	 * @param trgLoc the target locale.
	 * @param option the option to execute if there is no such container.
	 * @return the container for a given target locale. Can be null depending on the option.
	 * @see #getTarget(LocaleId)
	 */
	public ITextContainer getTarget (LocaleId trgLoc,
		GetTarget option);
	
	/**
	 * Indicates if this unit has a given target.
	 * @param trgLoc the target locale to lookup.
	 * @return true if there is a container for the given target, false otherwise.
	 */
	public boolean hasTarget (LocaleId trgLoc);

	/**
	 * Gets the object associated with a given span-class id in this unit.
	 * <p>The objects checked are: the parts (segments and non-segments) and all the 
	 * tags except the protected content markers.
	 * @param id the id to look for.
	 * @return the object found, or null if not found.
	 */
	public Object getObject (String id);

}
